package com.geh.learn.thread.completablefuture;

import org.apache.tools.ant.taskdefs.Sleep;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class BasicUsage {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ExecutorService es = Executors.newFixedThreadPool(10);
        Future<Integer> f = es.submit(() ->{
            // 需要进行一段长时间的异步计算
            Thread.sleep(1000);
            // 最后返回结果
            return 100;
        });

        System.out.println("The result is :" + f.get());

    }

}
